<template>
	<zh-sheet :margin="[30, 20]" :padding="[0,10]" color="grey-4" text :round="3">
		<view class="flex-row-center-between" @tap="gotoEnroll(null)">
			<view class="flex-row-center-start" >
				<zh-tag :followTheme="false" text :color="props.school.enrollStatus==='on'?'green':props.school.enrollStatus==='finish'?'red':'orange'" size="n" :label="props.school.enrollStatus==='on'?'招生中':props.school.enrollStatus==='finish'?'已结束':'未开始'"></zh-tag>
				<zh-text :label="props.school.schoolName" style="font-weight: 600;"></zh-text>
			</view>
			<zh-tag :shadow="5" v-if="props.school.enrollStatus==='on'&&props.school?.configList?.length===1" :followTheme="false" color="green" size="n"  label="报名"></zh-tag>
		</view>
		<view style="margin: 0 10rpx;" v-if="props.school?.configList?.length>1">
			<zh-cell @click="gotoEnroll(configItem)" v-for="(configItem,index) in props.school.configList" :key="index" :margin="[0, 0]" :padding="[0, 0]" :titleFontSize="30" :title="configItem.configTypeName">
			    <template v-slot:title>
					<view class="flex-row-center-start">
						<zh-text :label="configItem.configTypeName"></zh-text>
						<zh-tag :followTheme="false" text :color="configItem.enrollStatus==='on'?'green':configItem.enrollStatus==='finish'?'red':'orange'" size="n" :label="configItem.enrollStatus==='on'?'招生中':configItem.enrollStatus==='finish'?'已结束':'未开始'"></zh-tag>
					</view>
			        
			    </template>
				<template v-slot:right>
			        <zh-tag :shadow="5" v-if="configItem.enrollStatus==='on'" :followTheme="false" color="green" size="n" label="报名"></zh-tag>
			    </template>
			</zh-cell>
		</view>
		<zh-message ref="messageRef" :duration="2000"></zh-message>
	</zh-sheet>
</template>

<script lang="ts" setup>
	import {reactive,watch,ref,computed} from "vue";
	import { system } from '@/store';
	// ------------------接收传入参数(组件)-------------------
	const props = defineProps({
		school: {
		  type: Object,
		  default: () => {
			return {}
		  }
		},
		studentEnrollPreId:{
		  type: String,
		  default: '',
		},
	})
	const messageRef=ref();
	const elderFlag=computed(() => {return system.uiStyle==='elder'})
	const gotoEnroll=(item:any)=>{
		let messageData: any = {}
		messageData.model = 'warn'
		messageData.text = '招生工作已结束！'
		
		if(props.school.enrollStatus==='finish'){
			messageData.text = '该学校招生工作已结束！'
			messageRef.value.show(messageData)
			return
		}
		if(props.school.enrollStatus==='wait'){
			messageData.text = '该学校招生工作未开始！'
			messageRef.value.show(messageData)
			return
		}
		if(props.school.enrollStatus!=='on'){
			messageData.text = '该学校招生工作已结束，如有疑问请致电学校老师了解情况！'
			messageRef.value.show(messageData)
			return
		}
		let params={} as any
		params.schoolId=props.school.orgId
		params.studentEnrollPreId=props.studentEnrollPreId
		if(item){
			if(item.enrollStatus==='finish'){
				messageData.text = '该类型招生工作已结束！'
				messageRef.value.show(messageData)
				return
			}
			if(item.enrollStatus==='wait'){
				messageData.text = '该类型招生工作未开始！'
				messageRef.value.show(messageData)
				return
			}
			if(item.enrollStatus!=='on'){
				messageData.text = '该类型招生工作已结束，如有疑问请致电学校老师了解情况！'
				messageRef.value.show(messageData)
				return
			}
			params.configType=item.configType
			params.configTypeName=item.configTypeName
		}
		//跳转到报名页面
		$router.push('/pages/edu/enroll/enrollForm',params)
	}
</script>

<style lang="scss" scoped></style>